﻿@model ArticleClassifyEntity
@using XTeam.Core.Interface
@using System.Text
@{
    ViewBag.Title = "ClassifyPath";
    Layout = null;

    Func<IClassifyEntity, string> tree = null;
    tree = (IClassifyEntity parent) =>
    {
        StringBuilder sb = new StringBuilder();
        if (parent != null)
        {
            sb.Insert(0, Html.ActionLink(parent.ClassName, "ClassifyPath"
                , new { classid = parent.ClassId }, new { @class = "easyui-menubutton", menuid = parent.ClassId, menu = string.Format("#mm_{0}", parent.ClassId) }));
            sb.Insert(0, tree(parent.Parent));

            if (parent.Children != null && parent.Children.Count > 0)
            {
                sb.AppendLine(string.Format("<div id='mm_{0}' style='width:100px' class='pathmm'>", parent.ClassId));
                foreach (var item in parent.Children)
                {
                    if (item.Children != null && item.Children.Count > 0)
                    {
                        sb.AppendLine("<div iconCls='icon-folder'>");
                    }
                    else
                    {
                        sb.AppendLine("<div iconCls='icon-file'>");
                    }

                    sb.Append(Html.ActionLink(item.ClassName, "ClassifyPath", new { classid = item.ClassId }, new { @class = "pathmm_item", menuid = item.ClassId }));
                    sb.AppendLine("</div>");
                }
                sb.AppendLine("</div>");
            }
        }
        else
        {

        }
        return sb.ToString();
    };
    @Html.Raw(tree(Model))
}
